import React from 'react';
import { connect } from 'dva';
import { PrimaryC, PrimaryGhostC, SecondHeaderC, FixedButtonC } from '../../../comps';
import PropTypes from 'prop-types';
import { Row, Col } from 'antd';
import FormDataC from './formDataC';
import ChangeDataC from './changeDataC';
import ico from '../../../assets/busi/Product/right_arrow_select.png';
import myStyle from './index.less';
class TransitionData extends React.Component {
  constructor() {
    super();
    this.state = {};
  }

  componentDidMount() {
    this.props.onRef(this);
  }

  UNSAFE_componentWillReceiveProps(nextProps) {}

  getInfo = (type = '0') => {
    let query = type == '0' ? this.formData.getInfo() : this.formData1.getInfo();
    return query;
  };

  setInits = (data) => {
    this.formData1.setInits(data);
  };

  render() {
    const { form, loading, init, inits } = this.props;
    return (
      <FixedButtonC
        style={{ borderTop: '1px solid rgba(67, 118, 255, 0.1)' }}
        topHtml={
          <div>
            <Row style={{ width: '2730px' }}>
              <Col span={11}>
                <SecondHeaderC title='转换前' />
                <div>
                  <FormDataC type={3} init={init} onRef={(ref) => (this.formData = ref)} form={form} />
                </div>
              </Col>
              <Col span={2}>
                <div style={{ textAlign: 'center', marginTop: '485px' }}>
                  <img src={ico} />
                </div>
              </Col>
              <Col span={11}>
                <SecondHeaderC title='转换后' />
                <ChangeDataC init={inits} onRef={(ref) => (this.formData1 = ref)} secucodeChange={(e) => this.props.secucodeChange(e)} />
              </Col>
            </Row>
          </div>
        }
        bottomHtml={
          <div className={myStyle.outContainBox}>
            <PrimaryGhostC title='取消' onClick={() => this.props.onCancel()} style={{ marginRight: '10px' }} />
            <PrimaryC title='保存' onClick={() => this.props.onSave()} loading={loading} />
          </div>
        }
      ></FixedButtonC>
    );
  }
}

// props默认值
TransitionData.propsTypes = {
  init: PropTypes.object, // 基础信息
  inits: PropTypes.object,
  onCancel: () => {}, // 取消
  onSave: () => {}, // 保存
  secucodeChange: () => {}, // 转换切换证券代码
};

export default connect(({ nonstandarmaintenanceNewM }) => ({
  nonstandarmaintenanceNewM,
}))(TransitionData);
